package com.exam.util;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
 
import java.net.InetAddress;
import java.net.UnknownHostException;

 
@Component
public class ImgUtils {
 
    @Autowired
    Environment environment;
 
    public String getPort(){
        return environment.getProperty("local.server.port");
    }

    public String getHostIp(){
        InetAddress localHost = null;
        try {
            localHost = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
        }
        String ip = localHost.getHostAddress();  // 返回格式为：172.0.0.1
 
        return ip;
    }

}